bitkeeper revision 1.15.3.1 (3e3797e9gMcow8ShTTrYuWSeSSe-BA)
authorakw27@boulderdash.cl.cam.ac.uk <akw27@boulderdash.cl.cam.ac.uk>
Wed, 29 Jan 2003 08:59:21 +0000 (08:59 +0000)
committerakw27@boulderdash.cl.cam.ac.uk <akw27@boulderdash.cl.cam.ac.uk>
Wed, 29 Jan 2003 08:59:21 +0000 (08:59 +0000)
protect free_list with a spin lock.

xen-2.4.16/common/domain.c
xen-2.4.16/common/memory.c
xen-2.4.16/include/xeno/mm.h

index 1128cdfa15c737fec97b3659a62ca02be6da2f2e..fc71bad3ef7ec3171ca272577fcc99af9d381cff 100644 (file)
@@ -334,10 +334,13 @@ static unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes
     struct pfn_info *pf, *pf_head;
     unsigned int alloc_pfns;
     unsigned int req_pages;
+    unsigned long flags;
 
     /* how many pages do we need to alloc? */
     req_pages = kbytes >> (PAGE_SHIFT - 10);
 
+    spin_lock_irqsave(&free_list_lock, flags);
+    
     /* is there enough mem to serve the request? */   
     if(req_pages > free_pfns)
         return -1;
@@ -369,6 +372,8 @@ static unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes
 
         free_pfns--;
     }
+   
+    spin_unlock_irqrestore(&free_list_lock, flags);
     
     p->tot_pages = req_pages;
 
index 2e6697a0b80d20a3c2ca359177ac0d7222a3c90f..8cbed41416d1aa62a576c18947d8900d493f241f 100644 (file)
@@ -206,6 +206,7 @@ unsigned long frame_table_size;
 unsigned long max_page;
 
 struct list_head free_list;
+spinlock_t free_list_lock = SPIN_LOCK_UNLOCKED;
 unsigned int free_pfns;
 
 static int tlb_flush[NR_CPUS];
@@ -219,6 +220,7 @@ void __init init_frametable(unsigned long nr_pages)
 {
     struct pfn_info *pf;
     unsigned long page_index;
+    unsigned long flags;
 
     memset(tlb_flush, 0, sizeof(tlb_flush));
 
@@ -232,6 +234,7 @@ void __init init_frametable(unsigned long nr_pages)
     memset(frame_table, 0, frame_table_size);
 
     /* Put all domain-allocatable memory on a free list. */
+    spin_lock_irqsave(&free_list_lock, flags);
     INIT_LIST_HEAD(&free_list);
     for( page_index = (MAX_MONITOR_ADDRESS + frame_table_size) >> PAGE_SHIFT; 
          page_index < nr_pages; 
@@ -240,6 +243,7 @@ void __init init_frametable(unsigned long nr_pages)
         pf = list_entry(&frame_table[page_index].list, struct pfn_info, list);
         list_add_tail(&pf->list, &free_list);
     }
+    spin_unlock_irqrestore(&free_list_lock, flags);
 }
 
 
index 30071e76cfc659c0c25caf7668e10358c65dde74..3d014f650b6735ddf8462a5f4a029d151780a885 100644 (file)
@@ -7,6 +7,7 @@
 #include <asm/desc.h>
 #include <xeno/list.h>
 #include <hypervisor-ifs/hypervisor-if.h>
+#include <xeno/spinlock.h>
 
 /* XXX KAF: These may die eventually, but so many refs in slab.c :((( */
 
@@ -110,6 +111,7 @@ typedef struct pfn_info {
 extern frame_table_t * frame_table;
 extern unsigned long frame_table_size;
 extern struct list_head free_list;
+extern spinlock_t free_list_lock;
 extern unsigned int free_pfns;
 extern unsigned long max_page;
 void init_frametable(unsigned long nr_pages);